package dcc.app;

import java.util.HashMap;
import java.util.Map;

import javax.swing.JPanel;

import dcc.manager.base.InformationManager;
import dcc.manager.base.Manager;
import dcc.mbg.model.BaseInfo;
import dcc.tools.Tools;

public class ManagerGroup {

	private Map<String, Manager> managers;

	public ManagerGroup() {
		this.managers = new HashMap<String, Manager>();
	}

	public void add(String managerName) {
		try {
			this.managers.put(
					managerName,
					(Manager) Class.forName(
							Tools.get().getValue("MANAGERCLASSPATH")
									+ managerName).newInstance());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public Manager call(String managerName, JPanel workPanelHolder) {
		Manager m = this.managers.get(managerName);
		m.setWorkPanel(workPanelHolder);
		return m;
	}

	public void bindModelToManager(String managerName, BaseInfo baseInfo) {
		((InformationManager) this.managers.get(managerName))
				.bindModel(baseInfo);
	}
}
